package vip.liux.contracts.repositories.product;

import jakarta.validation.constraints.NotBlank;
import org.springframework.data.repository.ListCrudRepository;
import org.springframework.data.repository.ListPagingAndSortingRepository;
import org.springframework.data.repository.NoRepositoryBean;
import vip.liux.contracts.models.product.Category;
import vip.liux.contracts.shared.enums.product.CategoryType;

import java.util.Collection;
import java.util.List;
import java.util.Optional;

@NoRepositoryBean
public interface CategoryRepository extends ListPagingAndSortingRepository<Category, Long>, ListCrudRepository<Category, Long> {
    Optional<Category> findByCatNo(@NotBlank String catNo);

    boolean existsChildren(Long id);

    List<Category> findByParentNo(String parentNo);

    List<Category> findByCatNoIn(Collection<String> catNos);

    List<Category> findByType(CategoryType type);
}